package com.pzhu.record.service.impl;

import com.pzhu.record.entity.Graduation;
import com.pzhu.record.entity.Page;
import com.pzhu.record.service.GraduationService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Zhou YuSen
 * @date 2020/4/14 15:03
 */
@Service(value = "graduationService")
public class GraduationServiceImpl extends BaseServiceImpl implements GraduationService {
    @Override
    public int insert(Graduation graduation) {
        return 0;
    }

    @Override
    public int update(Graduation graduation) {
        return 0;
    }

    @Override
    public int delete(String id) {
        return 0;
    }

    @Override
    public int deleteAll(String[] pks) {
        return 0;
    }

    @Override
    public Graduation selectById(String id) {
        return null;
    }

    @Override
    public List<Graduation> selectAll() {
        return null;
    }

    @Override
    public int insertSelective(Graduation graduation) {
        return 0;
    }

    @Override
    public int insertBatch(List<Graduation> graduationList) {
        return graduationMapper.insertBatch(graduationList);
    }

    @Override
    public int updateBatch(List<Graduation> graduationList) {
        return graduationMapper.updateBatch(graduationList);
    }

    @Override
    public Page<Graduation> selectPage(int pageIndex, Graduation graduation) {
        Page<Graduation> page = new Page<>();
        List<Graduation> list = new ArrayList<>();
        page.setParamEntity(graduation);
        Integer pageNumber = selectPageCount(page);
        if (pageIndex < 1) {
            pageIndex = 1;
        }
        page.setPageIndex(pageIndex);
        page.setPageNumber(pageNumber);
        if (page.getPageNumber() % page.getPageSize() == 0) {
            page.setPageCount(page.getPageNumber() / page.getPageSize());
        } else {
            page.setPageCount(page.getPageNumber() / page.getPageSize() + 1);
        }
        list = graduationMapper.selectPageList(page);
        page.setList(list);
        return page;
    }

    @Override
    public Integer selectPageCount(Page<Graduation> bbsuserPage) {
        return graduationMapper.selectPageCount(bbsuserPage);
    }
}
